package com.zzyl.config;

import com.aliyun.iot20180120.Client;
import com.aliyun.teaopenapi.models.Config;
import com.zzyl.properties.AliIoTConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IotClientConfig {
    @Autowired
    private AliIoTConfigProperties aliIoTConfigProperties;

    /**
     * 返回一个客户端实例对象
     * @return
     */
    @Bean
    public Client instance() throws Exception {
        // 创建client客户端就需要config配置
        Config config = new Config();
        // 配置里面的属性
       config.accessKeyId = aliIoTConfigProperties.getAccessKeyId();
       config.accessKeySecret = aliIoTConfigProperties.getAccessKeySecret();
        // 设置它实例的地区
        config.regionId = aliIoTConfigProperties.getRegionId();
        return new Client(config) ;
    }
}
